<template>
	<div>
		<city-header></city-header>
		<city-search :cities="cities"></city-search>
		<city-list :cities="cities" :hotCities="hotCities" :letter="letter"></city-list>
		<city-alphabet :cities="cities" @change="handleLetterChange"></city-alphabet>
	</div>
</template>

<script>
	import axios from 'axios'
	import cityHeader from './components/Header'
	import citySearch from './components/Search'
	import cityList from './components/List'
	import cityAlphabet from './components/Alphabet'
	export default {
		name:'City',
		data() {
			return {
				cities: {},
				hotCities: [],
				letter: ''
			};
		},
		components: {
			cityHeader,
			citySearch,
			cityList,
			cityAlphabet
		},
		methods: {
			getCityInfo() {
				axios.get('/api/city.json').then(this.getCityInfoSucc)
			},
			getCityInfoSucc(res) {
				res = res.data;
				console.log(res)
				if(res.ret && res.data){
					let data = res.data;
					this.cities = data.cities;
					this.hotCities = data.hotCities;
				}
			},
			handleLetterChange(mes) {
				this.letter = mes;
			}
		},
		mounted() {
			this.getCityInfo();
		}
	}
</script>

<style lang="less" scoped>
    
</style>
